//
// Created by Administrator on 2025/9/30.
//

#ifndef CTEST_TEST11_H
#define CTEST_TEST11_H

#endif //CTEST_TEST11_H

#include <iostream>
#include <mutex>
#include <condition_variable>


#define T11V1 10
namespace Test11 {


    struct Test11C1 {
        int x;
        int y;

        Test11C1(int x, int y = 0) : x(x), y(y) {};

        Test11C1(const Test11C1 &a) {
            std::cout << "拷贝2";
            this->x = a.x;
            this->y = a.y;
        }

        void foo1();
    };

    class Test11C2 {
    private:
        int x;
        int y;

    public:
        Test11C2() = default;

    };


    class Test11C3 {

    private:
        mutable int x;
        int y;
        char *c;

    public:
        Test11C3() = default;

        Test11C3(int x, int y = 2, char *c = nullptr) : x(x), y(y), c(c) {};

        Test11C3(const Test11C3 &a) = default;

        ~Test11C3() = default;

        void foo1() const;

        friend void foo2(Test11C3 &c);

        static void foo3();
    };

    class Test11C4 {

    public:

        Test11C4() {
            std::cout << "parent init";
        };

        void foo1();

        virtual void foo3() = 0;
    };

    class Test11C5 : public Test11C4 {

    public:

        Test11C5() : Test11C4() {
            std::cout << "child init 1";
        };

        void foo2();

        void foo3() override;
    };

    class Test11C6 {

    public:

        Test11C6() = default;

        Test11C6 operator+(int a);

        Test11C6 operator++(int a);

    };


    class Addr {

    private:
        std::string *address;
        mutable std::string *email;

    public:
        Addr() = default;

        Addr(std::string *addr, std::string *emil) : address(addr), email(emil) {};

        void foo1() const;

        static void foo3(int *a, std::string *c);

        static void testException();

        operator int() const noexcept;
    };

    class MyException2 : public std::exception {
    private:
        std::string message;
    public:
        MyException2() : std::exception(), message("fuck bug") {
        }

        const char *what() const _GLIBCXX_TXN_SAFE_DYN _GLIBCXX_NOTHROW override;
    };

    template<typename T>
    concept is_db = std::is_floating_point_v<T>;

    template<is_db T>
    class Test11C7 {

    private :
        T t;

    public:
        void foo1() noexcept;
    };

    extern int t11GlobalV;

    class Test11C8 {

    private:
        std::mutex *m;
        std::condition_variable *c;
        std::unique_lock<std::mutex> *lock;
        volatile bool cond = false;
    public:
        Test11C8() {
            this->m = new std::mutex();
            this->c = new std::condition_variable();
            this->lock = new std::unique_lock(*this->m);
        };

        void testThread1();

        void setCondition();

        void foo1();
    };

    template<class T>
//    typename 用于方法 class 用于类和继承
    class Test11C9 {
    private:
        T t;
    };
}